#include <xpp/bas/Sio.h>
#include <xpp/bas/String.h>
#include <xp/bas/stdio.h>

using namespace xpp::bas;

int xp_main (int argc, xp_char_t* argv[])
{
	Sio sio;
	String line;

	if (argc != 2) {
		xp_printf (XP_TEXT("usage: %s file\n"), argv[0]);
		return -1;
	}

	if (sio.open (argv[1], XP_TEXT("r")) == -1) {
		xp_printf (XP_TEXT("cannot open %s\n"), argv[1]);
		return -1;
	}

	xp_tri_t n;

	while (1) {
		if ((n = sio.readLine (&line)) == xp_dead || n == xp_zombie) break;
		xp_printf (XP_TEXT("%d %s\n"), n, (xp_char_t*)line);
	}

	xp_printf (XP_TEXT("End of Program [%d]\n"), n);
	sio.close ();
	return 0;
}

